//
//  ZPBHeartOneCollectionReusableView.m
//  WZLProduct
//
//  Created by boys on 16/3/21.
//  Copyright © 2016年 HaiTeng. All rights reserved.
//

#import "ZPBHeartOneCollectionReusableView.h"


@implementation ZPBHeartOneCollectionReusableView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.titleLabel = [[UILabel alloc] init];
        [self addSubview:_titleLabel];
        
        self.upDataLabel = [[UILabel alloc] init];
        [self addSubview:_upDataLabel];
        
        self.moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        
        [_moreButton setTitle:@"更多" forState:(UIControlStateNormal)];
        
        [_moreButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_moreButton addTarget:self action:@selector(moreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_moreButton];
        
        self.moreImg = [[UIImageView alloc] init];
        [self addSubview:_moreImg];
        
    }
    return self;
}


-(void)setModel:(ZPBFirstGetModel *)model {
    
    _model = model;
    self.titleLabel.text = model.name;
    self.titleLabel.font = [UIFont systemFontOfSize:18];
    self.upDataLabel.text = model.desc;
    self.moreImg.image = [UIImage imageNamed:@"arrow-grey"];
    NSString *action = [NSString stringWithFormat:@"%@", model.action];
    if ([action isEqualToString:@"0"]) {
        self.moreImg.hidden = YES;
//        self.moreButton.hidden = YES;
    }else {
        self.moreButton.hidden = NO;
        self.moreImg.hidden = NO;
    }
    
    
    
}

- (void)moreButtonAction:(UIButton *)button {
    NSLog(@"1");
}


-(void)layoutSubviews {
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(18);
        make.top.offset(5);
        make.bottom.offset(-5);
        make.width.offset(kScreenWidth * 2 / 3);
    }];
    _titleLabel.font = [UIFont systemFontOfSize:19];
    _titleLabel.alpha = 0.8;
    
    [_upDataLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.height.equalTo(_titleLabel);
        make.left.offset(10 + kScreenWidth / 4 + 5);
        _upDataLabel.font = [UIFont systemFontOfSize:12];
    }];
    _upDataLabel.alpha = 0.5;
    [_moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(10);
        make.bottom.offset(-10);
        make.right.offset(-15);
        make.width.offset(kScreenWidth / 5);
    }];
    _moreButton.titleLabel.font = FONT15;
    _moreButton.alpha = 0.4;
    
    [_moreImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(15);
        make.bottom.offset(-15);
        make.right.offset(- 20);
        make.width.offset(10);
    }];
    
}
@end
